package com.theexceptions.todo.model;

/**
 * A filter that sorts tasks by finding those corresponding to a given category.
 * 
 * @author Justian Meyer
 */
public class CategoryFilter implements TaskFilter {

	private String category;

	/**
	 * Constructs a filter with a category to filter by.
	 * 
	 * @param category
	 */
	public CategoryFilter(String category) {
		this.category = category;
	}

	@Override
	public String getQuery() {
		String column = DatabaseHelper.TASKS_CATEGORY;

		if (category == null || category.equals("None"))
			return String.format("%s IS NULL", column);

		return String.format("%s = '%s'", column, category);
	}
}
